package com.k.demo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.k.demo.entity.CustomerUser;

@Mapper
public interface CustomerUserMapper {
	@Select ("select user_id, user_name, user_nickname, user_password, user_kind, user_point, user_true_name, to_char(birthday,'yyyy-mm-dd') birthday, " + 
			"to_char(register_date,'yyyy-mm-dd') register_date, sex, telephone, user_picture, head_img, is_delete from customer_user where (user_name=#{user_msg} or telephone=#{user_msg}) and user_password = #{user_pwd} and is_delete=1")
	CustomerUser selectByIdAndPwd(String user_msg,String user_pwd);
	
	int insertCustomerUser(CustomerUser customeruser);
	
	List<CustomerUser> selectAllCustomerUsers();
	
	List<CustomerUser> selectAllManagers();
	
	CustomerUser selectCustomerUserByUserid(int userid);
	
	@Select("select * from customer_user where user_kind=#{user_kind} and is_delete=1")
	List<CustomerUser> selectCustomerUserByKind(int user_kind);
	
	@Select("select * from customer_user where (user_name=#{user_msg} or to_char(user_id) = #{user_msg}) and is_delete=1")
	List<CustomerUser> selectCustomerUserByIdOrName(String user_msg);
	
	@Select("select * from customer_user where user_name=#{user_name} and is_delete=1")
	CustomerUser selectCustomerUserByUserName(String user_name);
	
	int updateUserinfo(CustomerUser customerUser);
	
	@Update("update customer_user set is_delete=0 where user_id=#{value} and is_delete=1")
	int deleteCustomerUser(int userid);
	
	int deleteCustomerUserForEach(List<Integer> userlist );
	
	List<CustomerUser> selectCustomerUserByKindAndName(CustomerUser customeruser);
	
	CustomerUser selectbyid(int user_id);
	
	List<CustomerUser> selectByIdList(List<Integer> user_id);
	
	@Select("select user_id from customer_user where instr(user_true_name,#{user_true_name})>0")
	List<Integer> getIdByName(String user_name);
	//查找全部用户
	List<CustomerUser> getAll();
	//组合查询用户
	List<CustomerUser> selectByUserInfo(CustomerUser customeruser);
}
